FROM registry.cn-hangzhou.aliyuncs.com/dragonwell/dragonwell:dragonwell-8.8.9_jdk8u302-ga_x86_64_slim as builder

# RUN mkdir -p /opt/apps/learn-api
WORKDIR application
COPY target/learn-blog-backend-0.0.1-SNAPSHOT.jar application.jar

RUN java -Djarmode=layertools -jar application.jar extract


# 二阶段
FROM registry.cn-hangzhou.aliyuncs.com/dragonwell/dragonwell:dragonwell-8.8.9_jdk8u302-ga_x86_64_slim
WORKDIR application
ENV TZ Asia/Shanghai
RUN ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime \
    && echo ${TZ} > /etc/timezone
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]